package com.euond.permission.dto;

import com.euond.common.core.dto.BaseDto;
import com.google.common.collect.Lists;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * Created by Daniel on 19/06/2017.
 * Menu Dto
 */

@Getter
@Setter
public class MenuDto extends BaseDto {
    private String name;
    private String icon;
    private String url;
    private List<MenuDto> children;
    private int sequence;
    private Long resourceId;
    private Long parentId;
    private String parentIds;


    public MenuDto(Long id, String name, String icon, String url,int sequence,Long resourceId,Long parentId, String parentIds) {
        setId(id);

        this.name = name;
        this.icon = icon;
        this.url = url;
        //前端需要进行排序
        this.sequence=sequence;
        this.resourceId=resourceId;
        this.parentId=parentId;
        this.parentIds=parentIds;
    }

    /**
     * 获取子菜单
     *
     * @return
     */
    public List<MenuDto> getChildren() {
        if (children == null) {
            children = Lists.newArrayList();
        }
        return children;
    }

    /**
     * 是否有子菜单
     *
     * @return
     */
    public boolean isHasChildren() {
        return !getChildren().isEmpty();
    }
}
